using UnityEngine;
using System.Collections;

public class Proyectil : MonoBehaviour
{

	public float mfProyectilSpeed;
	public Transform mParticles;
	
	// Use this for initialization
	void Start()
	{

	}

	// Update is called once per frame
	void Update()
	{
		float lfMove = mfProyectilSpeed * Time.deltaTime;
		transform.Translate(Vector3.forward * lfMove);
		
		if (gameObject.transform.position.z > 31.4f)  //si se va fuera del escenario
		{
			Destroy(gameObject);
		}
	
	
	}
	
	void OnTriggerEnter(Collider lCollider)
	//void OnTriggerEnter(GameObject lObject)
	{
		if (lCollider.collider.tag == "Pickup")
		{
			Instantiate(mParticles, collider.transform.position, Quaternion.identity);
			Destroy(gameObject);
			
			lCollider.gameObject.GetComponent<Block>().DestruirBloque();
			
			Sonidos.SP.Choque("ProyectilBloque");
			
			//Block lBlock;
			
			//lBlock = lObject;
			
			
			//lBlock.DestruirBloque();
		}
	}

}
